package com.csthink.auditlog.config;

import com.csthink.auditlog.config.aspect.AuditLoggingAspect;
import com.csthink.auditlog.config.builder.BaseAuditLogBuilder;
import com.csthink.auditlog.config.parser.AuditLogDetailParser;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import java.util.function.Supplier;

/**
 * @author <a href="mailto:security.2009@live.cn">Mars</a>
 * @since 2023-09-12
 */
@EnableAspectJAutoProxy
@Configuration
public class AuditLoggingConfiguration {

    @Bean
    public AuditLoggingAspect auditLoggingAspect(Supplier<BaseAuditLogBuilder> builderFactory) {
        return new AuditLoggingAspect(auditLogDetailParser(), builderFactory);
    }

    @Bean
    public AuditLogDetailParser auditLogDetailParser() {
        return new AuditLogDetailParser();
    }
}
